#include<iostream>
#include<algorithm>
using namespace std;
const int N=307;
const int M=1e7+7;
typedef struct Rode{
	int From;
	int To;
	int weight;
}rode;
rode r[M];
int pre[N],ans,Max,n,m;
bool cmp(rode a,rode b){
	return a.weight<b.weight;
}
int findRoot(int x){
	int root=x;
	while(pre[root]!=root)
		root=pre[root];
	return root;
}
int checkIfSameRoot(int x,int y){
	int root1=findRoot(x);
	int root2=findRoot(y);
	if(root1!=root2){
		pre[root1]=root2;
		return 1;
	}
	return 0;
}
void findAns(){
	for(int i=1;i<=m;i++){
		if(checkIfSameRoot(r[i].From,r[i].To)){
			ans++;
			Max=max(Max,r[i].weight);
		}
	}
	return;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		pre[i]=i;
	for(int i=1;i<=m;i++)
		cin>>r[i].From>>r[i].To>>r[i].weight;
	sort(r+1,r+m+1,cmp);
	findAns();
	cout<<ans<<" "<<Max<<endl;
	return 0;
}
